
//  购物车悬浮上盒子下来
var shopcar_Btn = document.querySelector('.shopcar')//购物车盒子
var cartMenu = document.querySelector('.cartMenu')//弹出的二级盒子
// console.log(1);
//购物车按钮放上去
if (shopcar_Btn) {
  shopcar_Btn.onmouseenter = function () {
    cartMenu.style.display = "block"
    animate(cartMenu, { height: 100 })
  }
  shopcar_Btn.onmouseleave = function () {
    animate(cartMenu, { height: 0 }, function () {
      cartMenu.style.display = "none"
    })
  }
}


$('.navlist ul li').mouseenter(function () {
  $('.navmenu').stop().slideDown()
})
$('.navlist').mouseleave(function () {
  $('.navmenu').stop().slideUp();
})

//   当登录成功右上角出现欢迎
if (selectCookie("keyusername")) {
  $('.h_right a').eq(0).replaceWith(`<p>欢迎${selectCookie("keyusername")}</p>`)
  $('.h_right a').eq(0).replaceWith(`<p class="exit">退出</p>`)
  exit()
} else {
  $('.h_right p').eq(0).replaceWith(`<a href="./login.html" class="hlogin">登录</a>`)
  $('.h_right p').eq(0).replaceWith(`<a href="./register.html" class="hregister">注册</a>`)
}

// 点击退出按钮删除cookie
function exit() {
  $('.exit').click(function () {
    layer.confirm('确认退出吗', {
      btn: ['残忍拒绝', '留在这里'] //按钮
    }, function () {
      deleteCookie("keyusername")
      location.href = "./home.html"
    }, function () {
      layer.msg('嗯嗯谢谢', {
        time: 2000, //20s后自动关闭

      });
    });
  })
}



$('#hidediv').height($('body').height())
$('.hregister').click(function () {
  $('#hidediv').show()
  $('.agreement').show()
  return false
})

$('.closeagree').click(function () {
  $('#hidediv').hide()
  $('.agreement').hide()
})
$('.notagree').click(function () {
  $('#hidediv').hide()
  $('.agreement').hide()
})

$('.agree').click(function () {
  location.href = "./register.html"
})

